﻿using System;
using System.Windows.Forms;

namespace CodeSnippet.Options
{
    /// <summary>
    /// Base class for all rule implementations targetting the <see cref="PropertyGrid"/> control.
    /// </summary>
    [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
    public abstract class RuleBaseAttribute : Attribute
    {
        #region Properties
        /// <summary>
        /// Gets or sets the error message.
        /// </summary>
        /// <value>The error message.</value>
        public string ErrorMessage { get; protected set; }
        #endregion Properties

        #region Overridables
        /// <summary>
        /// Determines whether the specified data object is valid.
        /// </summary>
        /// <param name="value">The data object.</param>
        /// <returns><c>true</c> if the specified data object is valid; otherwise, <c>false</c>.</returns>
        public abstract bool IsValid(object value);
        #endregion Overridables
    }
}
